package com.cmf.myproject.controller.system.sysparam;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cmf.myproject.dal.mybatis.model.SysParam;
import com.cmf.myproject.service.system.sysparam.SysParamService;
import com.cmf.myproject.service.system.sysparam.dto.SysParamAddItemReqDto;
import com.cmf.myproject.service.system.sysparam.dto.SysParamQueryFilter;
import com.cmf.myproject.service.system.sysparam.dto.SysParamUpdateItemReqDto;
import com.system.core.controller.ControllerBase;
import com.system.core.results.ResultBase;
import com.system.core.view.layui.table.TableViewRspDto;

@Controller
@RequestMapping("boss/sys_param")
public class SysParamController extends ControllerBase {
	@Autowired
	private SysParamService sysParamService;
	
	@RequiresPermissions("sysParam_topage")
	@RequestMapping(value = "to_page",method = RequestMethod.GET)
	public String toPage() {
		return "/system/sysParam/sysParam-list";
	}
	
	@RequestMapping(value = "query_list",method = RequestMethod.POST)
	@ResponseBody
	public TableViewRspDto<SysParam> sysParamQueryList(SysParamQueryFilter filter) {
		TableViewRspDto<SysParam> rsp = sysParamService.sysParamList(filter);
		return rsp;
	}
	
	@RequestMapping(value = "get_item_by_key",method = RequestMethod.POST)
	@ResponseBody
	public SysParam sysParamGetByPrimaryKey(SysParam sysParam){
		return sysParamService.sysParamGetByPrimaryKey(sysParam);
	}
	
	@RequiresPermissions("sysParam_add_opt")
	@RequestMapping(value = "add_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysParamAddItem(@Validated SysParamAddItemReqDto sysParamAddItemReqDto) {
		return sysParamService.sysParamSave(sysParamAddItemReqDto);
	}
	
	@RequiresPermissions("sysParam_edit_opt")
	@RequestMapping(value = "update_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysParamUpdateItem(@Validated SysParamUpdateItemReqDto sysParamUpdateItemReqDto) {
		return sysParamService.sysParamUpdateByPrimaryKey(sysParamUpdateItemReqDto);
	}
	
	@RequiresPermissions("sysParam_delete_opt")
	@RequestMapping(value = "delete_item",method = RequestMethod.POST)
	@ResponseBody
	public ResultBase sysParamDeleteItem(@RequestBody List<Long> keys) {
		return sysParamService.sysParamDeleteByPrimaryKey(keys);
	}
}
